package com.kevin.collection;

import java.util.*;

public class HashMapTest {
    public static void main(String[] args) {
        HashMap<User,String> map = new HashMap<>();
        User user = new User("123");
        User user1 = new User("123");
        map.put(user,"test1");
        map.put(user1,"test2");
        System.out.println(map.get(user1));
        System.out.println(map.size());



    }

}
class User{
    private String name;
    private String psw;

    public User(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPsw() {
        return psw;
    }

    public void setPsw(String psw) {
        this.psw = psw;
    }

    @Override
    public boolean equals(Object obj) {
        User user = (User)obj;
        return this.name==user.name;
    }

    @Override
    public int hashCode() {
        return 1;
    }
}
